<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkFileChooserButton extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sTitle=$this->getProperty_($oObject,'title',G::L('请选择...','Dyhb'));// 对话框参数
		$sAction=$this->getProperty_($oObject,'action','GTK_FILE_CHOOSER_ACTION_OPEN');
		$sOverwriteConfirmation=$this->getProperty_($oObject,'do_overwrite_confirmation','false');
		$sMultiple=$this->getProperty_($oObject,'select_multiple','false');
		$sOnlyLocal=$this->getProperty_($oObject,'local_only','true');
		$sPreviewWidgetActive=$this->getProperty_($oObject,'preview_widget_active','true');
		$sUsePreviewLabel=$this->getProperty_($oObject,'use_preview_label','true');
		$sShowHidden=$this->getProperty_($oObject,'show_hidden','false');
		$sAction=str_replace('GTK_','Gtk::',$sAction);
		// 创建对话框和按钮
		$sCompiled="
		\$oDlg=new GtkIoDialog(Gtk::FILE_CHOOSER_ACTION_OPEN,'{$sTitle}');// 创建 文件目录选择对话框
		\$wndDlg=\$oDlg->getWidget();
		{$sVariableName}={$sWidgetClass}::new_with_dialog(\$wndDlg);// 创建 按钮
		\$oDlg->setOverwriteConfirmation({$sOverwriteConfirmation});
		\$wndDlg->set_action({$sAction});
		\$wndDlg->set_select_multiple({$sMultiple});
		\$wndDlg->set_local_only({$sOnlyLocal});
		\$wndDlg->set_preview_widget_active({$sPreviewWidgetActive});
		\$wndDlg->set_use_preview_label({$sUsePreviewLabel});
		\$wndDlg->set_show_hidden({$sShowHidden});
	
";
		$this->setBool_($oObject,$sCompiled,'focus_on_click');// 点击获得焦点
		$this->setStringInt_($oObject,$sCompiled,'spacing',false);// 间距
		$this->setStringInt_($oObject,$sCompiled,'width_chars',false);// 字符宽度
		$this->setBool_($oObject,$sCompiled,'homogeneous');// 统一大小
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
